package com.mayikt.days07;

import java.lang.ref.WeakReference;

/**
 * @ClassName Test005
 * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
 * @Version V1.0
 **/
public class Test005 {
    public static void main(String[] args) {
        OrderEntity order1 = new OrderEntity("644064", "mayikt");
        // 强引用
//        OrderEntity order2 = order1;
//        order1 = null;
//        System.out.println(order2);
//        System.gc();
//        System.out.println(order2);

        // 弱引用
        WeakReference<OrderEntity> order2 = new WeakReference<>(order1);
        order1 = null;
        System.out.println(order2.get());
        System.gc();
        System.out.println(order2.get());
    }
}
